#include <iostream>
#include <stdio.h>
#include <vector>
#include <stdlib.h>
#define ffor(i,max) for(int i = 0 ; i < max ; i++)
using namespace std;

int main1()
{
	freopen("datain.txt","r",stdin);
//    freopen("dataout.txt","w",stdout);
    int count_repeater = 0;
    string s_t;
    cin>>s_t;
    const char * c_count = s_t.c_str();
    count_repeater = atoi(c_count);

    if(count_repeater == 0)
        return 1;

    bool map[count_repeater][count_repeater];
    ffor(i,count_repeater)
    ffor(j,count_repeater)
        map[i][j] = false;
//    for(int i = 0 ; i < count_repeater ; i++)
//    {
//        ffor(j,count_repeater)
//            cout<<map[i][j]<<" ";
//        cout<<endl;
//    }

    for(int i = 0 ; i < count_repeater ; i++)//readin array
    {
        cin>>s_t;
        int col=0,row=0;
        row=s_t[0]-'A';
        for(int j = 2 ; j < s_t.length() ; j++)
        {
            col = s_t[j] - 'A';
            map[row][col] = true;
        }
    }




	return 0;
}
























